package com.codingbetter.streamconsumer.service;

import com.codingbetter.common.Book;
import com.codingbetter.streamconsumer.config.BookBinding;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Service;
import org.springframework.messaging.Message;

/**
 * @author Tony Zhang
 **/
@Service
@EnableBinding(BookBinding.class)
public class BookConsumer {
    @StreamListener(BookBinding.BOOK_IN)
    public void consume(Message<Book> bookMessage) {
        Book book = bookMessage.getPayload();
        System.out.println("Consume book: " + book);
    }
}
